package com.winning.sx.microframework.common.config;

import java.text.SimpleDateFormat;
import java.util.Date;


public class FileUploadConfig {

	// 1.本地素材的相关文档文件-文件，附件
	static String uploadDocumentPath =Config.uploadDiskPath+ "/upload/document";

	public static String getUploadDocumentPath(String typeCode) {

		return uploadDocumentPath + "/" + getTypeCodePath(typeCode) + "/" + getDayPath() + "/";
	}

	// 2.本地素材的封面图片文件
	static String uploadResourcePicPath = Config.uploadDiskPath+"/upload/resourcePic";

	public static String getUploadResourcePicPath(String typeCode) {

		return uploadResourcePicPath + "/" + getTypeCodePath(typeCode) + "/" + getDayPath() + "/";
	}

	// 3.微信的封面图片文件
	static String uploadWxPicPath = Config.uploadDiskPath+"/upload/wxPic";

	public static String getUploadWxPicPath(String coustomId) {

		return uploadWxPicPath + "/" + coustomId + "/" + getDayPath() + "/";
	}

	// 4.pdfExe转换hmtl程序文件地址
	public static String pdf2HtmlExePath = "D:/Projects/Java/ME2017/passRelease/WebRoot/resource/Tools/pdf2htmlEXv1.0";
	// 5.本地素材的相关文档文件-图片
	static String uploadNewsImagePath = Config.uploadDiskPath+"/upload/newsImages";
	static String uploadNewsImagePathWeb = Config.uploadDiskPath+"/upload/newsImages";
	public static String getUploadNewsImagePath(){
		System.out.println("uploadConfig:--------------------------------"+uploadNewsImagePath);
		return uploadNewsImagePath+"/" + getDayPath() + "/";
	}
	public static String getUploadNewsImagePathWeb(){
		return uploadNewsImagePathWeb+"/" + getDayPath() + "/";
	}
	
	private static String getDayPath() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM");
		Date date = new Date();
		return sdf.format(date);
	}

	private static String getTypeCodePath(String typeCode) {
		String typePath = "";
		switch (typeCode.length()) {
		case 3:
			typePath = typeCode;
			break;
		case 6:
			typePath = typePath.substring(0, 3) + "/" + typeCode;
			break;
		case 9:
			typePath = typePath.substring(0, 3) + "/" + typePath.substring(0, 6) + "/" + typeCode;
			break;
		case 12:
			typePath = typePath.substring(0, 3) + "/" + typePath.substring(0, 6) + "/" + typePath.substring(0, 9) + "/"
					+ typeCode;
			break;
		case 15:
			typePath = typePath.substring(0, 3) + "/" + typePath.substring(0, 6) + "/" + typePath.substring(0, 9)
					+ typePath.substring(0, 12) + "/" + typeCode;
			break;
		default:
			typePath = typeCode;
		}
		return typePath;
	}


}
